package com.ybkj.o2o.zhuanxian.service.impl;

import com.ybkj.o2o.zhuanxian.entity.CarAndLine;
import com.ybkj.o2o.zhuanxian.mapper.CarAndLineMapper;
import com.ybkj.o2o.zhuanxian.service.CarAndLineService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DefaultCarAndLineService implements CarAndLineService {

  @Autowired
  private CarAndLineMapper carAndLineMapper;

  @Override
  public int insert(CarAndLine cal) {
    return carAndLineMapper.insert(cal);
  }

  @Override
  public List<CarAndLine> findByCar(Long carId) {

    return carAndLineMapper.findByCar(carId);
  }

  @Override
  public List<CarAndLine> findByLineName(String lineName) {
    return carAndLineMapper.findByLineName(StringUtils.isNotBlank(lineName)?"%"+lineName+"%":null);
  }

  //  @Override
//  public int deleteByCar(Long carid) {
//
//    return carAndLineMapper.deleteByCar(carid);
//  }
  @Override
  public int deleteByCar(Long carid, Long lineId) {
    return carAndLineMapper.deleteByCar(carid, lineId);
  }

  @Override
  public int deleteByLine(Long carid) {

    return carAndLineMapper.deleteByLine(carid);
  }

  @Override
  public int updateLineNameByLine(Long id, String name) {

    return carAndLineMapper.updateLineNameByLine(id, name);
  }

  @Override
  public int updateCarNameByCar(Long id, String carName) {

    return carAndLineMapper.updateCarNameByCar(id, carName);
  }

  @Override
  public List<CarAndLine> findByLine(Long lineId) {

    return carAndLineMapper.findByLine(lineId);
  }

}
